home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 June / CHIP Haziran 2001.iso / prog / share / 17 / dings_e.exe / Compiler / Bin / DirectInput.h < prev    next >
C/C++ Source or Header  |  2001-02-06  |  2KB  |  60 lines

  1. // --- DirectInput.h
  2.  
  3.  
  4. // --- defines ---
  5. #if !defined(DIRECTINPUT_CLASS_INCLUDED)
  6. #define DIRECTINPUT_CLASS_INCLUDED
  7.  
  8. #include <dinputd.h>
  9. #include <dinput.h>
  10.  
  11. #define HR(error)  MAKE_HRESULT(1, 0x000, error)
  12. #define    DXIN_MAX_JOYSTICKS        4
  13.  
  14. #define DINPUT_OK                1
  15. #define DINPUT_ERROR            0
  16. #define CANT_CREATE_DINPUT        HR(10)
  17. #define NO_ACCESS_ON_KEYBOARD    HR(11)
  18. #define NO_ACCESS_ON_MOUSE        HR(12)
  19.  
  20. // --- structure for mousedata ---
  21. struct DIMOUSEDATA
  22. {
  23.     short Button1, Button2, Button3;
  24.     short AccX, AccY;    
  25. };
  26.  
  27. BOOL FAR PASCAL                    g_EnumJoystick(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef);
  28. static    LPDIRECTINPUTDEVICE        g_lpDID;
  29.  
  30. // --- class constructor ---
  31. class DirectInput
  32. {
  33. public:
  34.     DirectInput();
  35.     ~DirectInput();
  36.  
  37.     HRESULT    CreateDInput(HWND hWnd, HINSTANCE hInstance); // Init DInput
  38.     void    GetKeyboardStatus(); // Freeze current buffer
  39.     bool    GetKey(unsigned char Key); // Get DI-Key Status
  40.     bool    AnyKey(); // Is Any Key Pressed?
  41.     char    GetKeyChar(void); // Get the char that has been pressed
  42.     bool    GetMouseData(DIMOUSEDATA *Data); // Freeze Mousedata to stuct
  43.     bool    AnyMouse(); // Is any Mousebutton down?
  44.     bool    GetJoystickData(DIJOYSTATE* Data, char num); // Get Josytick Information
  45.  
  46. private:
  47.     LPDIRECTINPUT            lpDInput;        
  48.     LPDIRECTINPUTDEVICE        lpDIDKeyboard;
  49.     LPDIRECTINPUTDEVICE        lpDIDMouse;    
  50.     LPDIRECTINPUTDEVICE2    lpDIDJoystick[DXIN_MAX_JOYSTICKS];    
  51.  
  52. protected:
  53.     BYTE m_KeyBuffer[256];
  54.     BYTE m_MapBuffer[256];
  55.     void DXtoVK(bool DXActive);
  56. };
  57.  
  58. #endif // DIRECTINPUT_CLASS_INCLUDED
  59.  
  60.